conditional-test.js ➔ main   A
last analyzed

Complexity

Conditions 3

Size

Total Lines 18
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 11
dl 0
loc 18
rs 9.85
c 0
b 0
f 0
cc 3
1
import { spawn, execSync } from 'child_process';
2
import path from 'path';
3
import {
4
    getTestCommand,
5
    getPrepareCommands
6
} from '../utils';
7
8
async function main() {
9
    const { platform, versions } = process;
10
11
    console.log(JSON.stringify({ platform, versions }));
0 ignored issues
show
Debugging Code introduced by
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
12
    // eslint-disable-next-line security/detect-non-literal-require
13
    const packageJSON = require(path.join(process.cwd(), 'package.json'));
14
    const config = packageJSON['node-package-tester'];
15
    const testCommand = getTestCommand(config, { platform, versions });
16
    const prepareCommands = getPrepareCommands(config, { platform, versions });
17
18
    for (const prepareCommand of prepareCommands) {
19
        execSync(prepareCommand);
20
    }
21
22
    const childProcess = spawn('npm', [ 'run', testCommand ], { shell: true, stdio: 'inherit' });
23
24
    childProcess.on('exit', (code) => process.exit(code));
0 ignored issues
show
Compatibility Debugging Code Best Practice introduced by
Use of process.exit() is discouraged as it will potentially stop the complete node.js application. Consider quitting gracefully instead by throwing an Error.
Loading history...
25
}
26
27
main();
28
29